import tkinter as tk
import pyautogui as ag
import random
from time import sleep as Delay
from math import sqrt, sin, cos, pi 
def Window_Open(W, H):
    X, Y = ag.size()
    winSize = str(W)+"x"+str(H)
    winPos = winSize + "+" + str((X - W) // 2)
    winPos += "+" + str((Y - H) // 2)
    win.geometry(winPos)
    win.resizable(False, False)
    title = u'桌面分辨率：' + str(X) + "x" + str(Y)
    title += ' ' * 5 + u'窗体大小：' + winSize
    win.title(title)
    win.update()
 
def Rect2(x,y,w,rad=45,c='black'):
    a=pi*rad/180
    coord = (x - w * sin(a)/sqrt(2),y - w * cos(a)/sqrt(2),
             x + w * cos(a)/sqrt(2),y - w * sin(a)/sqrt(2),
             x + w * sin(a)/sqrt(2),y + w * cos(a)/sqrt(2),
             x - w * cos(a)/sqrt(2),y + w * sin(a)/sqrt(2))
    tCanvas.create_polygon(coord,fill=c)
 
if __name__ == '__main__':
    
    win = tk.Tk()
    Window_Open(900,600)
    tCanvas = tk.Canvas(win, width=win.winfo_width(), height=600, bg='white')
    tCanvas.pack(side="top")

    Color = ['Azure','LightCyan','PaleTurquoise'\
        ,'Cyan','Aqua','DarkTurquoise','DarkCyan', "Teal", "MediumTurquoise"]
 
    w=50
    w=280
    for r in range(45,1216,5):
        c = random.choice(Color)
        Rect2(580,300,w,r,c)
        tCanvas.update()
        w *= 0.99
        Delay(0.001)
 
    win.mainloop()
 





